<?php
/**
 * Created by PhpStorm.
 * User: wincol
 * Date: 2018/3/14
 * Time: 21:42
 */

namespace App\Helper;


class Helper
{
    public static function returnSuccess($data=null, $code=ErrorCode::SUCCESS){
        $res = [
            'code'=>$code,
            'data'=>$data,
        ];
        return json_encode($res,JSON_UNESCAPED_UNICODE);
    }
    public static function returnError($code=-1,$msg=null){
        $res = [
            'code'=>$code,
            'msg'=>$msg,
        ];
        return json_encode($res,JSON_UNESCAPED_UNICODE);
    }
    //添加密码盐
    public static function saltGen($num){
        $scale = 'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM';
        $scale = str_split ($scale);
        shuffle($scale);
        $salt = implode('', $scale);
        return substr($salt, 1, $num);
    }
    //生成token
    public static function tokenGen($string){
        return md5($string.time());
    }

}